package com.example.yupao_project.config;

import com.example.yupao_project.component.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * mvc配置类
 * @author: 杰
 * @date: 2024/5/1 10:31
 */
@Configuration
public class MvcConfigure implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptor loginInterceptor;

    /**
     * 配置拦截器
     * @param registry 注册器
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("user/**")
                .addPathPatterns("team/**")
                .excludePathPatterns("user/login")// TODO: 2024/5/1 配置拦截路径（待完成）
                .excludePathPatterns("user/register");// TODO: 2024/5/1 配置拦截路径（待完成）
    }
}
